package com.itheima.io1.mytest2;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;
import java.util.ArrayList;

/**
 * @author zhangbaiyan
 * @date 2024-09-21 20:28
 * @description:
 * @version:
 */
public class test {
    public static void main(String[] args) throws IOException {

        //1.序列化多个对象
        Student s1 = new Student("张三", 23, "深圳");
        Student s2 = new Student("李四", 24, "深圳");
        Student s3 = new Student("王五", 25, "深圳");
        ArrayList<Student> students = new ArrayList<>();
        students.add(s1);
        students.add(s2);
        students.add(s3);

        ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream("su.txt"));
        oos.writeObject(students);

        oos.close();
    }
}
